package com.nkzy.mapper;

import com.nkzy.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface CategoryMapper {

    @Select("SELECT * FROM category WHERE id = #{id}")
    Category selectById(Integer id);

    @Select("SELECT * FROM category")
    List<Category> selectAll();

    @Insert("INSERT INTO category(category_name, category_alias, create_user, create_time, update_time) " +
            "VALUES(#{categoryName}, #{categoryAlias}, #{createUser}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Category category);

    @Update("UPDATE category SET category_name = #{categoryName}, category_alias = #{categoryAlias}, " +
            "create_user = #{createUser}, update_time = #{updateTime} WHERE id = #{id}")
    void update(Category category);

    @Delete("DELETE FROM category WHERE id = #{id}")
    void deleteById(Integer id);
}